//Saturday, October 31 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class CellRemoval
{
public:
	int N;
	vector<vector<int> > v;
	int cellsLeft(vector <int> parent, int deletedCell)
	{
		N = parent.size();
		vector<int> temp;
		for(int i=0; i<N; i++)
			v.push_back(temp);
		int root = 0;
		for(int i=0; i<N; i++)
		{
			if(-1 == parent[i])
				root = i;
			else
				v[parent[i]].push_back(i);
		}
		return dfs(root, deletedCell);
	}
	int dfs(int k, int deletedCell)
	{
		if(k == deletedCell) return 0;
		if(v[k].empty()) return 1;
		int ret = 0;
		for(int i=0; i<v[k].size(); i++)
			ret += dfs(v[k][i], deletedCell);
		return ret;
	}
};
